package com.yl.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yl.exception.CustomException;
import com.yl.mapper.UserRoleMapper;
import com.yl.model.entity.UserRoleEntity;
import com.yl.service.UserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRoleEntity> implements UserRoleService {

    @Resource
    private UserRoleMapper userRoleMapper;

    @Override
    public Boolean removeRole(Long userId) {
        int i = userRoleMapper.removeRole(userId);
        if(i==0) throw new CustomException("删除用户角色表数据失败");
        return true;
    }
}
